
'''
    >>> for i in fib(10): print i
    1
    1
    2
    3
    5
    8

    >>> for i in fib(): # doctest: +ELLIPSIS
    ...   print i
    ...   if i == 3111581989804070186099320645726169127737705: break
    ...
    1
    1
    ...
    3111581989804070186099320645726169127737705

'''

def fib(max=None):
    a = b = 1
    while (max is None) or (a <= max):
       yield a
       a, b = b, a + b

if __name__ == '__main__':
    import doctest
    doctest.testmod()
